<?php
	$username=$_GET["username"];
	if ($username){
		try{
			$conn=mysql_connect("127.0.0.1","root","");
			if ($conn){
				mysql_select_db("dbOpenFire", $conn);
				try{
					$results=mysql_query("SELECT username FROM ofVCard WHERE username NOT IN (SELECT username FROM ofPresence) AND (TRIM(vcard) LIKE ('%<RANDOMCHATSTATUS>1</RANDOMCHATSTATUS>%')) AND (TRIM(vcard) LIKE ('%<RANDOMCHATOCCUP>0</RANDOMCHATOCCUP>%')) AND username!='user01'");
					if ($results){
						$numberOfRows=mysql_num_rows($results);
						if ($numberOfRows > 0)
							echo mysql_result($result, rand(0, $numberOfRows-1));
					}
				}
				catch (Exception $e)
					echo "ERROR:".$e;
			}
			else
				echo "ERROR:CONNERR";
		}
		catch{
			echo "ERROR:CONNERR";
		}
	}
	else
		echo "ERROR:NPARAMFND";
?>